<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            下单日期：<input type="text" name="orderDate"/>
                        </li>

                        <li>
                            订单价格：<input type="text" name="orderPrice"/>
                        </li>

                        <li>
                            订单商品：<input type="text" name="bookId"/>
                        </li>

                        <li>
                            订单数量：<input type="text" name="orderCount"/>
                        </li>

                        <li>
                            下单用户Id：<input type="text" name="userId"/>
                        </li>

                        <li>
                            用户地址：<input type="text" name="userAddress"/>
                        </li>

                        <li>
                            订单状态：<input type="text" name="state"/>
                        </li>

                        <li>
                            店铺Id：<input type="text" name="storeId"/>
                        </li>

                        <li>
                            ：<input type="text" name="level"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:orderbuy:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()"
               shiro:hasPermission="system:orderbuy:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:orderbuy:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:orderbuy:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:orderbuy:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:orderbuy:remove')}]];
    var prefix = ctx + "system/orderbuy";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "订单",
            showExport: true,
            columns: [{
                checkbox: true
            },
                {
                    field: 'orderId',
                    title: '订单Id',
                    visible: false
                },
                {
                    field: 'orderDate',
                    title: '下单日期',
                    sortable: true
                },
                {
                    field: 'orderPrice',
                    title: '订单价格',
                    sortable: true
                },
                {
                    field: 'bookId',
                    title: '订单商品',
                    sortable: true
                },
                {
                    field: 'orderCount',
                    title: '订单数量',
                    sortable: true
                },
                {
                    field: 'userId',
                    title: '下单用户Id',
                    sortable: true
                },
                {
                    field: 'userAddress',
                    title: '用户地址',
                    sortable: true
                },
                {
                    field: 'state',
                    title: '订单状态',
                    sortable: true
                },
                {
                    field: 'storeId',
                    title: '店铺Id',
                    sortable: true
                },
                {
                    field: 'level',
                    title: '',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.orderId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="fahuo(\'' + row.orderId + '\')"><i class="fa fa-edit"></i>发货</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.orderId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function fahuo(e) {
        var id = $(e).selector;
        console.log(id);
        $.ajax({
            type: "post",
            url: "/system/orderbuy/fahuo",
            data: {
                orderId: id
            },
            dataType: "json",
            success: function (json) {
                if (json.msg === 0) {

                } else if (json.msg === 1) {

                }
            }
        });
    }
</script>
</body>
</html>